import { http } from '@/utils/request'

// 修改单位
export function updateUnit(data: any) {
  return http.request({
    url: `/small/myUnit/updateUnit`,
    method: 'POST',
    data
  })
}

// 解绑成员
export function unBindMemberUnitRelation(data: any) {
  return http.request({
    url: `/small/myUnit/unBindMemberUnitRelation`,
    method: 'POST',
    data
  })
}

// 绑定成员
export function bindMemberUnitRelation(data: any) {
  return http.request({
    url: `/small/myUnit/bindMemberUnitRelation`,
    method: 'POST',
    data
  })
}

// 添加单位
export function addUnit(data: any) {
  return http.request({
    url: `/small/myUnit/addUnit`,
    method: 'POST',
    data
  })
}

// 全部单位列表
export function selectUnitList(params: any) {
  return http.request({
    url: `/small/myUnit/selectUnitList`,
    method: 'GET',
    params
  })
}

// 单位详情
export function selectUnitDetail(unitId: string | number) {
  return http.request({
    url: `/small/myUnit/selectUnitDetail/${unitId}`,
    method: 'GET'
  })
}

// 通过单位数量
export function selectMyUnitNumber() {
  return http.request({
    url: `/small/myUnit/selectMyUnitNumber`,
    method: 'GET'
  })
}

// 我的单位列表
export function selectMyUnitList(params: any) {
  return http.request({
    url: `/small/myUnit/selectMyUnitList`,
    method: 'GET',
    params
  })
}

// 我的家庭成员列表
export function selectMyFamilyMemberListByUnit(unitId: string | number) {
  return http.request({
    url: `/small/myUnit/selectMyFamilyMemberList/${unitId}`,
    method: 'GET'
  })
}

// 加入单位
export function joinUnit(unitId: string | number) {
  return http.request({
    url: `/small/myUnit/joinUnit/${unitId}`,
    method: 'GET'
  })
}

// 删除单位
export function deleteUnit(id: string | number) {
  return http.request({
    url: `/small/myUnit/deleteUnit/${id}`,
    method: 'DELETE'
  })
}
